<?php
/**
 * 发仔<i@fazi.me> 2018-07-09
 */

namespace app\open\model;

use traits\model\SoftDelete;
class CarMaintenance extends Base
{
    use SoftDelete;
    protected $deleteTime = 'delete_time';
    protected $autoWriteTimestamp = true;

    public function car(){
        return $this->hasOne('Car','car_id','car_id','car','left')->setEagerlyType(0);
    }
    public function service(){
        return $this->hasOne('service','service_id','service_id','service','left')->setEagerlyType(0);
    }

    /**
     * 通过审批
     * @param $id
     * @return int
     */
    public function pass($id) {
        return $this->where('id',$id)->fetchSql(0)->setField('state',2);
    }
}